import request from '@/utils/request'
import { toolConvey } from './convey'

// 状态设置
// 使用类
// import { Status } from '@/api/statusInfo'
// const cls = new Status();
// cls.setApi('aaa')
// cls.enable();

// 创建类
export class Status {
  // api;
  setApi(api){
    this.api = api
  }
  // 开启
  enable(id,postType,field) {
    let quest = {}
    if(field){
      quest[field] = id
    }else {
      quest['id'] = id
    }
    return request({
      url: this.api + `/admin/${ postType }/enable`,
      method: 'post',
      data: quest
    })
  }
  // 关闭
  stop(id,postType,field) {
    let quest = {}
    if(field){
      quest[field] = id
    }else {
      quest['id'] = id
    }
    return request({
      url: this.api + `/admin/${ postType }/disable`,
      method: 'post',
      data: quest
    })
  }
  // 计划 状态
  setStatus (account_id,param) {  // { advertiser_id, ad_ids:[],opt_status:'' }
    return toolConvey(account_id,'2/ad/update/status/',param,'POST')
  }
  // 批量开启
  batchEnable(ids,postType) {
    return request({
      url: this.api + `/admin/${ postType }/batch_enable`,
      method: 'post',
      data: { ids:ids }
    })
  }
  // 批量关闭
  batchStop(ids,postType) {
    return request({
      url: this.api + `/admin/${ postType }/batch_disable`,
      method: 'post',
      data: { ids:ids }
    })
  }
}

